import requests


class DepApi:
    #封装添加部门的方法
    @classmethod
    def add_dep_api(cls,token,add_dep_body):
        add_dep_url = "http://ihrm2-test.itheima.net/api/company/department"
        add_dep_header = {"Content-Type": "application/json", "Authorization": token}
        add_dep_resp = requests.post(url=add_dep_url, headers=add_dep_header, json=add_dep_body)
        return add_dep_resp

    # 封装查询部门的方法
    @classmethod
    def query_dep_api(cls,dep_id,token):
        query_dep_url = f"http://ihrm2-test.itheima.net/api/company/department/{dep_id}"
        query_dep_header = {"Authorization": token}
        query_dep_resp = requests.get(url=query_dep_url, headers=query_dep_header)
        return query_dep_resp

    # 封装修改部门的方法
    @classmethod
    def modify_dep_api(cls,dep_id,token,modify_dep_body):
        modify_dep_url = f"http://ihrm2-test.itheima.net/api/company/department/{dep_id}"
        modify_dep_header = {"Content-Type": "application/json", "Authorization": token}
        modify_dep_resp = requests.put(url=modify_dep_url, headers=modify_dep_header, json=modify_dep_body)
        return modify_dep_resp

    # 封装删除部门的方法
    @classmethod
    def delete_dep_api(cls,dep_id,token):
        del_dep_url = f"http://ihrm2-test.itheima.net/api/company/department/{dep_id}"
        del_dep_header = {"Authorization": token}
        del_dep_resp = requests.delete(url=del_dep_url, headers=del_dep_header)
        return del_dep_resp


